00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef LVSHBL_HPP
00011 #define LVSHBL_HPP
00012 #include "gridpack/component/data_collection.hpp"
00013 #include "gridpack/parser/dictionary.hpp"
00014 #include "gridpack/utilities/string_utils.hpp"
00015 namespace gridpack {
00016 namespace parser {
00017 template <class _data_struct> class LvshblParser
00018 {
00019 public:
00020
00021
00022
00023 explicit LvshblParser()
00024 {
00025 }
00026
00027
00028
00029
00030 virtual ~LvshblParser()
00031 {
00032 }
00033
00034
00035
00036
00037
00038
00039
00040 void extract(_data_struct &data_struct,
00041 gridpack::component::DataCollection *data)
00042 {
00043 double rval;
00044 int ival, r_id;
00045 bool bval;
00046 std::string stmp;
00047
00048 if (!data->getValue(RELAY_NUMBER,&ival)) {
00049 ival = 0;
00050 data->addValue(RELAY_NUMBER, ival+1);
00051 } else {
00052 data->setValue(RELAY_NUMBER, ival+1);
00053 }
00054 r_id = ival;
00055
00056
00057 if (!data->getValue(RELAY_MODEL,&stmp,r_id)) {
00058 data->addValue(RELAY_MODEL, data_struct.model, r_id);
00059 } else {
00060 data->setValue(RELAY_MODEL, data_struct.model, r_id);
00061 }
00062
00063
00064 if (!data->getValue(RELAY_LID,&stmp,r_id)) {
00065 data->addValue(RELAY_LID, data_struct.tag, r_id);
00066 } else {
00067 data->setValue(RELAY_LID, data_struct.tag, r_id);
00068 }
00069
00070
00071 if (!data->getValue(RELAY_JBUS,&ival,r_id)) {
00072 data->addValue(RELAY_JBUS, data_struct.jbus, r_id);
00073 } else {
00074 data->setValue(RELAY_JBUS, data_struct.jbus, r_id);
00075 }
00076
00077
00078 if (!data->getValue(RELAY_V1,&rval,r_id)) {
00079 data->addValue(RELAY_V1, data_struct.v1, r_id);
00080 } else {
00081 data->setValue(RELAY_V1, data_struct.v1, r_id);
00082 }
00083
00084
00085 if (!data->getValue(RELAY_T1,&rval,r_id)) {
00086 data->addValue(RELAY_T1, data_struct.t1, r_id);
00087 } else {
00088 data->setValue(RELAY_T1, data_struct.t1, r_id);
00089 }
00090
00091
00092 if (!data->getValue(RELAY_F1,&rval,r_id)) {
00093 data->addValue(RELAY_F1, data_struct.f1, r_id);
00094 } else {
00095 data->setValue(RELAY_F1, data_struct.f1, r_id);
00096 }
00097
00098
00099 if (!data->getValue(RELAY_V2,&rval,r_id)) {
00100 data->addValue(RELAY_V2, data_struct.v2, r_id);
00101 } else {
00102 data->setValue(RELAY_V2, data_struct.v2, r_id);
00103 }
00104
00105
00106 if (!data->getValue(RELAY_T2,&rval,r_id)) {
00107 data->addValue(RELAY_T2, data_struct.t2, r_id);
00108 } else {
00109 data->setValue(RELAY_T2, data_struct.t2, r_id);
00110 }
00111
00112
00113 if (!data->getValue(RELAY_F2,&rval,r_id)) {
00114 data->addValue(RELAY_F2, data_struct.f2, r_id);
00115 } else {
00116 data->setValue(RELAY_F2, data_struct.f2, r_id);
00117 }
00118
00119
00120 if (!data->getValue(RELAY_V3,&rval,r_id)) {
00121 data->addValue(RELAY_V3, data_struct.v3, r_id);
00122 } else {
00123 data->setValue(RELAY_V3, data_struct.v3, r_id);
00124 }
00125
00126
00127 if (!data->getValue(RELAY_T3,&rval,r_id)) {
00128 data->addValue(RELAY_T3, data_struct.t3, r_id);
00129 } else {
00130 data->setValue(RELAY_T3, data_struct.t3, r_id);
00131 }
00132
00133
00134 if (!data->getValue(RELAY_F3,&rval,r_id)) {
00135 data->addValue(RELAY_F3, data_struct.f3, r_id);
00136 } else {
00137 data->setValue(RELAY_F3, data_struct.f3, r_id);
00138 }
00139
00140
00141 if (!data->getValue(RELAY_TB,&rval,r_id)) {
00142 data->addValue(RELAY_TB, data_struct.tb, r_id);
00143 } else {
00144 data->setValue(RELAY_TB, data_struct.tb, r_id);
00145 }
00146 }
00147
00148
00149
00150
00151
00152
00153
00154
00155 void parse(std::vector<std::string> &split_line,
00156 gridpack::component::DataCollection *data)
00157 {
00158 double rval;
00159 int nstr = split_line.size();
00160 int ival, r_id;
00161
00162
00163 if (!data->getValue(RELAY_NUMBER,&ival)) {
00164 ival = 0;
00165 data->addValue(RELAY_NUMBER, ival+1);
00166 } else {
00167 data->setValue(RELAY_NUMBER, ival+1);
00168 }
00169 r_id = ival;
00170
00171
00172 std::string stmp, model;
00173 gridpack::utility::StringUtils util;
00174 model = util.trimQuotes(split_line[1]);
00175 util.toUpper(model);
00176 if (!data->getValue(RELAY_MODEL,&stmp,r_id)) {
00177 data->addValue(RELAY_MODEL, model.c_str(), r_id);
00178 } else {
00179 data->setValue(RELAY_MODEL, model.c_str(), r_id);
00180 }
00181
00182
00183 if (nstr > 2) {
00184 model = util.clean2Char(split_line[2]);
00185 if (!data->getValue(RELAY_LID,&stmp,r_id)) {
00186 data->addValue(RELAY_LID, model.c_str(), r_id);
00187 } else {
00188 data->setValue(RELAY_LID, model.c_str(), r_id);
00189 }
00190 }
00191
00192
00193 if (nstr > 3) {
00194 if (!data->getValue(RELAY_JBUS,&ival,r_id)) {
00195 data->addValue(RELAY_JBUS, atoi(split_line[3].c_str()), r_id);
00196 } else {
00197 data->setValue(RELAY_JBUS, atoi(split_line[3].c_str()), r_id);
00198 }
00199 }
00200
00201
00202 if (nstr > 4) {
00203 if (!data->getValue(RELAY_V1,&rval,r_id)) {
00204 data->addValue(RELAY_V1, atof(split_line[4].c_str()), r_id);
00205 } else {
00206 data->setValue(RELAY_V1, atof(split_line[4].c_str()), r_id);
00207 }
00208 }
00209
00210
00211 if (nstr > 5) {
00212 if (!data->getValue(RELAY_T1,&rval,r_id)) {
00213 data->addValue(RELAY_T1, atof(split_line[5].c_str()), r_id);
00214 } else {
00215 data->setValue(RELAY_T1, atof(split_line[5].c_str()), r_id);
00216 }
00217 }
00218
00219
00220 if (nstr > 6) {
00221 if (!data->getValue(RELAY_F1,&rval,r_id)) {
00222 data->addValue(RELAY_F1, atof(split_line[6].c_str()), r_id);
00223 } else {
00224 data->setValue(RELAY_F1, atof(split_line[6].c_str()), r_id);
00225 }
00226 }
00227
00228
00229 if (nstr > 7) {
00230 if (!data->getValue(RELAY_V2,&rval,r_id)) {
00231 data->addValue(RELAY_V2, atof(split_line[7].c_str()), r_id);
00232 } else {
00233 data->setValue(RELAY_V2, atof(split_line[7].c_str()), r_id);
00234 }
00235 }
00236
00237
00238 if (nstr > 8) {
00239 if (!data->getValue(RELAY_T2,&rval,r_id)) {
00240 data->addValue(RELAY_T2, atof(split_line[8].c_str()), r_id);
00241 } else {
00242 data->setValue(RELAY_T2, atof(split_line[8].c_str()), r_id);
00243 }
00244 }
00245
00246
00247 if (nstr > 9) {
00248 if (!data->getValue(RELAY_F2,&rval,r_id)) {
00249 data->addValue(RELAY_F2, atof(split_line[9].c_str()), r_id);
00250 } else {
00251 data->setValue(RELAY_F2, atof(split_line[9].c_str()), r_id);
00252 }
00253 }
00254
00255
00256 if (nstr > 10) {
00257 if (!data->getValue(RELAY_V3,&rval,r_id)) {
00258 data->addValue(RELAY_V3, atof(split_line[10].c_str()), r_id);
00259 } else {
00260 data->setValue(RELAY_V3, atof(split_line[10].c_str()), r_id);
00261 }
00262 }
00263
00264
00265 if (nstr > 11) {
00266 if (!data->getValue(RELAY_T3,&rval,r_id)) {
00267 data->addValue(RELAY_T3, atof(split_line[11].c_str()), r_id);
00268 } else {
00269 data->setValue(RELAY_T3, atof(split_line[11].c_str()), r_id);
00270 }
00271 }
00272
00273
00274 if (nstr > 12) {
00275 if (!data->getValue(RELAY_F3,&rval,r_id)) {
00276 data->addValue(RELAY_F3, atof(split_line[12].c_str()), r_id);
00277 } else {
00278 data->setValue(RELAY_F3, atof(split_line[12].c_str()), r_id);
00279 }
00280 }
00281
00282
00283 if (nstr > 13) {
00284 if (!data->getValue(RELAY_TB,&rval,r_id)) {
00285 data->addValue(RELAY_TB, atof(split_line[13].c_str()), r_id);
00286 } else {
00287 data->setValue(RELAY_TB, atof(split_line[13].c_str()), r_id);
00288 }
00289 }
00290 }
00291
00292
00293
00294
00295
00296
00297 void store(std::vector<std::string> &split_line,_data_struct &data)
00298 {
00299
00300 int o_idx;
00301 o_idx = atoi(split_line[0].c_str());
00302 data.bus_id = o_idx;
00303
00304 std::string sval;
00305 gridpack::utility::StringUtils util;
00306 sval = util.trimQuotes(split_line[1]);
00307 util.toUpper(sval);
00308
00309
00310 strcpy(data.model, sval.c_str());
00311 int nstr = split_line.size();
00312
00313
00314 if (nstr > 2) {
00315 sval = util.clean2Char(split_line[2]);
00316 strcpy(data.tag, sval.c_str());
00317 }
00318
00319
00320 if (nstr > 3) {
00321 data.jbus = atoi(split_line[3].c_str());
00322 }
00323
00324
00325 if (nstr > 4) {
00326 data.v1 = atof(split_line[4].c_str());
00327 }
00328
00329
00330 if (nstr > 5) {
00331 data.t1 = atof(split_line[5].c_str());
00332 }
00333
00334
00335 if (nstr > 6) {
00336 data.f1 = atof(split_line[6].c_str());
00337 }
00338
00339
00340 if (nstr > 7) {
00341 data.v2 = atof(split_line[7].c_str());
00342 }
00343
00344
00345 if (nstr > 8) {
00346 data.t2 = atof(split_line[8].c_str());
00347 }
00348
00349
00350 if (nstr > 9) {
00351 data.f2 = atof(split_line[9].c_str());
00352 }
00353
00354
00355 if (nstr > 10) {
00356 data.v3 = atof(split_line[10].c_str());
00357 }
00358
00359
00360 if (nstr > 11) {
00361 data.t3 = atof(split_line[11].c_str());
00362 }
00363
00364
00365 if (nstr > 12) {
00366 data.f3 = atof(split_line[12].c_str());
00367 }
00368
00369
00370 if (nstr > 13) {
00371 data.tb = atof(split_line[13].c_str());
00372 }
00373 }
00374 };
00375 }
00376 }
00377 #endif